<?php if (!defined('THINK_PATH')) exit();?>  <style>
    #preview, .img, img  
    {  
        width:150px;  
        //height:150px;  
    }
</style>
<div class="pageContent" style="width:800px;height:600px">	
    <form method="post" action="/tuyouApp/admin/Topphoto/edit?callbackType=closeCurrent" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone)">
        <input type='hidden' name='id' value="<?php echo ($userInfo['id']); ?>"/>
        <div class="pageFormContent" layoutH="58">
            <div class="unit">
                <label>图片名：</label>
                <input type="text" name="name" size="30" minlength="3" maxlength="30" class="required" value="<?php echo ($photo["name"]); ?>"/>
            </div>            
            <div class="unit">
                <label>图片预览：</label>
                <div id="preview" style="border-left-width: 27px; margin-left: 126px;"><img src="<?php echo (PUBLIC_URL); echo ($photo["image"]); ?>" style="padding-left: 0px;"/></div>
                <input type="file" id="file"  name="image" value="" onchange="preview(this)" style="margin-left: 124px;"/><br/>
            </div> 
            <div class="unit">
                <label>图片链接：</label>
                <input type="text" name="contentUrl" size="30"  class="alphanumeric" value="<?php echo ($photo["contenturl"]); ?>"/>
            </div>
        </div>
        <div class="formBar">
            <ul>
                <li><div class="buttonActive"><div class="buttonContent"><button type="submit">提交</button></div></div></li>
                <li><div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div></li>
            </ul>
        </div>
    </form>	
</div>
<script>
    //头像预览
        function preview(file)  
        {  
            var prevDiv = document.getElementById('preview');  
            if (file.files && file.files[0])  
            {  
            var reader = new FileReader();  
            reader.onload = function(evt){  
            prevDiv.innerHTML = '<img src="' + evt.target.result + '" />';  
           }    
            reader.readAsDataURL(file.files[0]);  
           }  
            else    
            {  
            prevDiv.innerHTML = '<div class="img" style="filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src=\'' + file.value + '\'"></div>';  
            }  
        }  
</script>